//
//  CellOfPic.m
//  ProjectA_ManualGuest
//
//  Created by dingcong on 16/6/15.
//  Copyright © 2016年 丁聪. All rights reserved.
//

#import "CellOfPic.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
#import "PrefixHeader.pch"
@implementation CellOfPic

- (void)dealloc{
    
    [_imageO release];
    [_lableOfDate release];
    [_lableOfName release];
    [_lableOfState release];
    [_model release];
    [super dealloc];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self creat];
        self.backgroundColor = [UIColor clearColor];
    }
    
    return self;
    
    
    
    
    
}


- (void)creat
{
    
    UIView *viewOfBackbround = [[UIView alloc]init];
    [self.contentView addSubview:viewOfBackbround];
    
    [viewOfBackbround mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView.mas_top).offset(10);
        make.leading.equalTo(self.contentView.mas_leading).offset(0);
        make.height.equalTo(self.contentView.mas_height).offset(- 10);
        make.width.equalTo(self.contentView.mas_width);
        
        
    }];
    viewOfBackbround.backgroundColor = [UIColor colorWithRed:244.0f / 255.0f green:244.0f / 255.0f blue:244.0f / 255.0f alpha:0.5];
    self.contentView.backgroundColor = [UIColor colorWithRed:244.0f / 255.0f green:244.0f / 255.0f blue:244.0f / 255.0f alpha:0.5];
    
    
    self.imageO = [[UIImageView alloc]init];
    [viewOfBackbround addSubview:self.imageO];
//    self.imageO.backgroundColor = [UIColor greenColor];
    [self.imageO mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(viewOfBackbround.mas_leading).offset(0);
        make.top.equalTo(viewOfBackbround.mas_top).offset(0);
        make.height.equalTo(self.contentView.mas_height).offset(- 60);
        make.width.equalTo(self.contentView.mas_width);
    }];
    [self.imageO release];
    self.imageO.layer.cornerRadius = 25;
    self.imageO.layer.masksToBounds = YES;

    
    self.lableOfName = [[UILabel alloc]init];
    [viewOfBackbround addSubview:self.lableOfName];
//    self.lableOfName.backgroundColor = [UIColor yellowColor];
    [self.lableOfName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(self.contentView.mas_leading).offset(8);
        make.top.equalTo(self.imageO.mas_bottom).offset(3);
        make.width.offset(SCREEN_WIDTH - 80);
        make.height.offset(20);
        
    }];
    [self.lableOfName release];
    
    
    self.lableOfDate = [[UILabel alloc]init];
    [viewOfBackbround addSubview:self.lableOfDate];
//    self.lableOfDate.backgroundColor = [UIColor colorWithRed:244.0f green:244.0f blue:244.0f alpha:0.5];
    [self.lableOfDate mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(self.contentView.mas_leading).offset(8);
        make.top.equalTo(self.lableOfName.mas_bottom).offset(4);
        make.width.equalTo(self.lableOfName.mas_width);
        make.height.equalTo(self.lableOfName.mas_height);
        
    }];
    [self.lableOfDate release];
    
    
    self.lableOfState = [[UILabel alloc]init];
    
    
    
    [viewOfBackbround addSubview:self.lableOfState];
//    self.lableOfState.backgroundColor = [UIColor grayColor];
    [self.lableOfState mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.lableOfDate.mas_trailing).offset(8);
        make.centerY.equalTo(self.lableOfDate.mas_centerY);
        make.width.offset(60);
        make.height.equalTo(self.lableOfName.mas_height);
    }];
    
    self.lableOfName.textColor = [UIColor grayColor];
    self.lableOfName.font = [UIFont systemFontOfSize:14];
    
    
    self.lableOfDate.textColor = [UIColor grayColor];
    self.lableOfDate.font = [UIFont systemFontOfSize:14];
    
    self.lableOfState.textColor = [UIColor blackColor];
    self.lableOfState.font = [UIFont systemFontOfSize:14 weight:0.4];
    [self.lableOfState release];
}


- (void)setModel:(ActivityModel *)model{
   
    NSLog(@"1111%@", model.m_logo);
    [self.imageO sd_setImageWithURL:[NSURL URLWithString:model.m_logo] placeholderImage:nil];
    
    NSString *str = @"征集时间: ";
    self.lableOfName.text = model.c_name;
    self.lableOfDate.text = [str stringByAppendingString:model.c_time] ;
    
    if (model.c_status == 1)
    {
        self.lableOfState.text = @"进行中";
       
    }
    else
    {
        self.lableOfState.text = @"已结束";
    }
    
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
